<!DOCTYPE html>
<html>
<head>
    <title>面积调剂</title>
<#include "../common/common.ftl"/>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row  layui-col-space10">
        <div class="layui-col-xs12">
            <div class="layui-card">
                <div class="layui-card-header">【${(outContract.name)!}(<span
                        class="jmdf-color-red">${(outContract.contractCode)!}</span>)】➜【${(inContract.name)!}(<span
                        class="jmdf-color-red">${(inContract.contractCode)!}</span>)】面积调剂登记
                </div>
                <div class="layui-card-body">
                    <form class="layui-form" action="">
                        <input type="hidden" name="outContractId" value="${(outContract.id)!}"/>
                        <input type="hidden" name="inContractId" value="${(inContract.id)!}"/>
                        <div class="layui-card">
                            <div class="layui-card-header">一、调剂转出方基本信息</div>
                            <div class="layui-card-body">
                                <div class="layui-form-item">
                                    <div class="layui-col-xs6">
                                        所在项目：${(outContract.zsProject.projectName)!}
                                    </div>
                                    <div class="layui-col-xs6">
                                        所在工作组：${(groupMap[outContract.groupCode].name)!}
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <div class="layui-col-xs6">
                                        协议编号：${(outContract.contractCode)!}
                                    </div>
                                    <div class="layui-col-xs6">
                                        被动迁人姓名：${(outContract.name)!}
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <div class="layui-col-xs6">
                                        总可选房面积：${(outContract.limitHouseAreaTotal)!}㎡
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-card">
                            <div class="layui-card-header">二、调剂转入方基本信息</div>
                            <div class="layui-card-body">
                                <div class="layui-form-item">
                                    <div class="layui-col-xs6">
                                        所在项目：${(inContract.zsProject.projectName)!}
                                    </div>
                                    <div class="layui-col-xs6">
                                        所在工作组：${(groupMap[inContract.groupCode].name)!}
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <div class="layui-col-xs6">
                                        协议编号：${(inContract.contractCode)!}
                                    </div>
                                    <div class="layui-col-xs6">
                                        被动迁人姓名：${(inContract.name)!}
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <div class="layui-col-xs6">
                                        总可选房面积：${(inContract.limitHouseAreaTotal)!}㎡
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-card">
                            <div class="layui-card-header">三、本次调剂面积</div>
                            <div class="layui-card-body">
                                <div class="layui-form-item">
                                    <div class="layui-col-xs12">
                                        <div class="layui-inline">
                                            <label class="layui-form-label">调剂面积：</label>
                                            <div class="layui-input-inline">
                                                <input type="text" class="layui-input" autocomplete="off" name="area"
                                                       placeholder="必填项" lay-verify="area"/>
                                            </div>
                                            <div class="layui-form-mid jmdf-color-red">
                                                *（可输入的区间范围【0-${(outContract.limitHouseAreaTotal)!}】）
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <button style="display: none;" class="layui-btn " id="submitBtn" name="submitBtn" lay-submit=""
                                lay-filter="submit">立即提交
                        </button>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="/layui/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form', 'jquery'], function () {
        var form = layui.form, $ = layui.jquery;

        //监听提交
        form.on('submit(submit)', function (data) {
            $.ajax({
                url: 'setAreaSave',
                type: 'post',
                data: data.field,//当前容器的全部表单字段，名值对形式：{name: value}
                success: function (data) {
                    if (data.code == "0001") {
                        layer.msg(data.message, {anim: 0, icon: 1, time: 1000}, function () {
                            parent.location.reload();
                        });
                    } else {
                        layer.msg(data.message, {anim: 6, icon: 2, time: 3000});
                    }
                }
            });
            return false;
        });

        //自定义验证规则
        form.verify({
            area: function (value) {
                var r = /^(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*))$/;
                var area = $("input:text[name='area']").val();
                var limitHouseAreaTotal = ${(outContract.limitHouseAreaTotal)!};
                if (value != undefined) {
                    if (!r.test(value) || (area - limitHouseAreaTotal) > 0) {
                        return "请输入【0-" + limitHouseAreaTotal + "】之间的数字！";
                    }
                } else {
                    return '必填项不允许为空！';
                }
            }
        });
    });
</script>
</body>
</html>